<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:thSys="">
<div th:replace="admin/module/macros :: head('系统设置')"></div>
<body class="app sidebar-mini rtl">
	<main class="app-content">
	<div th:replace="admin/module/macros :: header"></div>
	<div th:replace="admin/module/macros :: sidebar"></div>
	<div class="app-title">
		<div>
			<h1>
				<i class="fa fa-dashboard"></i> 博客设置
			</h1>
		</div>
		<ul class="app-breadcrumb breadcrumb">
			<li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
			<li class="breadcrumb-item"><a href="#">博客设置</a></li>
		</ul>
	</div>
	<div class="row">
		<div class="col-lg-12 col-md-12 tile">
			<div class="bs-component">
				<ul class="nav nav-tabs" role="tablist">
					<li class="nav-item"><a class="nav-link active"
						data-toggle="tab" href="#routine">常规设置</a></li>
					<li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#seo">SEO设置</a></li>
					<li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#article">文章设置</a></li>
					<li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#comment">评论设置</a></li>
					<li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#attachment">附件设置</a></li>
					<!-- <li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#admin">后台设置</a></li>-->
					<li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#email">邮箱设置</a></li>
					<li class="nav-item"><a class="nav-link" data-toggle="tab"
						href="#other">其他设置</a></li>
				</ul>
				<!-- Tab panes -->
				<div class="tab-content">
					<div id="routine" class="tab-pane active">
						<form class="form-horizontal" id="commonOptions">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">博客标题：</label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['blog_name']}" name="blog_name">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">博客地址：</label>
								<div class="col-md-5">
									<input class="form-control" type="text" name="blog_url"
										th:value="${options['blog_url']}">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">首页LOGO：</label>
								<div class="col-md-5">
									<div class="input-group">
										<input class="form-control" type="text" readonly="readonly"
											name="blog_logo" id="blog_logo"
											th:value="${options['blog_logo']}"> <span
											class="input-group-btn">
											<button class="btn btn-default " type="button"
												th:onclick="'javascript:openChoice(\''+blog_logo+'\')'">选择</button>
										</span>
									</div>
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">Favicon：</label>
								<div class="col-md-5">
									<div class="input-group">
										<input class="form-control" type="text" name="ico_logo"
											readonly="readonly" id="ico_logo"
											th:value="${options['ico_logo']}"> <span
											class="input-group-btn">
											<button class="btn btn-default " type="button"
												th:onclick="'javascript:openChoice(\''+ico_logo+'\')'">选择</button>
										</span>
									</div>
								</div>
							</div>
							<div class="form-group row">
								<label class="control-label col-md-2">页脚信息：</label>
								<div class="col-md-5">
									<div class="input-group">
										<textarea class="form-control" title="支持HTML" rows="3"
											th:text="${options['blog_footer']}"
											th:value="${options['blog_footer']}" id="" name="blog_footer"
											style="resize: none"></textarea>
									</div>
								</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('commonOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
					<!-- SEO表单 -->
					<div id="seo" class="tab-pane fade">
						<form class="form-horizontal" id="seoOptions">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">关键词： <span
									data-toggle="tooltip" data-placement="top" title="多个关键词使用,隔开"
									style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['seo_keyword']}" name="seo_keyword">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">博客描述：</label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['seo_describe']}" name="seo_describe">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">百度推送token： <span
									data-toggle="tooltip" data-placement="top" title="百度站长平台获取"
									style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<div class="input-group">
										<input type="text" class="form-control" id="baiduToken"
											th:value="${options['seo_baidu_token']}"
											name="seo_baidu_token"> <span class="input-group-btn">
											<button class="btn btn-default" onclick="pushBaidu()"
												type="button">推送</button>
										</span>
									</div>
								</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('seoOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
					<!-- 文章 -->
					<div id="article" class="tab-pane fade">
						<form class="form-horizontal" id="articleOptions">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">首页显示条数： <span
									data-toggle="tooltip" data-placement="top" title="默认为12条"
									style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['index_article']}" name="index_article">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">RSS显示条数：</label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['rss_number']}" name="rss_number">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">文章摘要字数：</label>
								<div class="col-md-5">
									<div class="input-group">
										<input type="text" class="form-control" name="post_summary"
											th:value="${options['post_summary']}">
									</div>
								</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('articleOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
					<!-- 评论 -->
					<div id="comment" class="tab-pane fade">
						<form class="form-horizontal" id="commentOptions">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">platform:</label>
								<div class="col-md-5">
									<div class="animated-radio-button mt-2">
										<label><input class="form-control" value="gitalk"
											type="radio"
											th:checked="${options['platform_comment'] == 'gitalk'}"
											name="platform_comment"><span class="label-text">Gitalk</span></label>
										<label><input class="form-control" value="valine"
											type="radio"
											th:checked="${options['platform_comment'] == 'valine'}"
											name="platform_comment"><span class="label-text">Valine</span></label>
									</div>
								</div>
							</div>
							<div class="gitalk-options" style="display: none">
						<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">clientID:<span
									data-toggle="tooltip" data-placement="top"
									title="GitHub Application Client ID." style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_gitalk_clientid']}"
										name="comment_gitalk_clientid">
								</div>
						</div>
						<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">clientSecret:<span
									data-toggle="tooltip" data-placement="top"
									title="GitHub Application Client Secret." style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_gitalk_clientSecret']}"
										name="comment_gitalk_clientSecret">
								</div>
						</div>
						<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">repo:<span
									data-toggle="tooltip" data-placement="top"
									title="GitHub仓库名称" style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_gitalk_repo']}"
										name="comment_gitalk_repo">
								</div>
						</div>
						<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">owner:<span
									data-toggle="tooltip" data-placement="top"
									title="GitHub仓库所有者，可以是个人或者组织。" style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_gitalk_owner']}"
										name="comment_gitalk_owner">
								</div>
						</div>
						<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">admin:<span
									data-toggle="tooltip" data-placement="top"
									title="GitHub仓库的所有者和合作者" style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_gitalk_admin']}"
										name="comment_gitalk_admin">
								</div>
						</div>
						</div>
							<div class="valine-options" style="display: none">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">APP ID:<span
									data-toggle="tooltip" data-placement="top"
									title="Leancloud申请的appid" style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_valine_appid']}"
										name="comment_valine_appid">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">APP KEY:<span
									data-toggle="tooltip" data-placement="top"
									title="Leancloud申请的appkey" style="cursor: pointer"> <i
										class="fa fa-question-circle" aria-hidden="true"></i>
								</span></label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_valine_appkey']}"
										name="comment_valine_appkey">
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">头像类型:</label>
								<div class="col-md-5">
									<select class="form-control" name="comment_valine_portrait">
										<option
											th:selected="${options['comment_valine_portrait']=='identicon'}"
											value="identicon">抽象几何图形</option>
										<option
											th:selected="${options['comment_valine_portrait']=='monsterid'}"
											value="monsterid">小怪物</option>
										<option
											th:selected="${options['comment_valine_portrait']=='wavatar'}"
											value="wavatar">wavatar</option>
										<option
											th:selected="${options['comment_valine_portrait']=='retro'}"
											value="retro">复古</option>
										<option
											th:selected="${options['comment_valine_portrait']=='robohash'}"
											value="robohash">机器人</option>
										<option
											th:selected="${options['comment_valine_portrait']=='hide'}"
											value="hide">不显示头像</option>
									</select>
								</div>
							</div>
							<div class="form-group row">
								<label class="col-form-label col-md-2">占位提示:</label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['comment_valine_hint']}"
										name="comment_valine_hint">
								</div>
							</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('commentOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
					<!-- 附件 -->
					<div id="attachment" class="tab-pane fade">
						<form class="form-horizontal" id="attachmentOptions">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">储存位置:</label>
								<div class="col-md-5">
									<div class="animated-radio-button mt-2">
										<label> <input type="radio" value="server"
										name="attachment_location" th:checked="${options['attachment_location'] == 'server'}"><span
											class="label-text">本地服务器</span>
										</label>
										<label> <input type="radio" th:value="qiniu"
										name="attachment_location" th:checked="${options['attachment_location'] == 'qiniu'}" disabled=""><span
											class="label-text">七牛云</span>
										</label>
										<label> <input type="radio" th:value="upyun"
										name="attachment_location" th:checked="${options['attachment_location'] == 'upyun'}" disabled=""><span
											class="label-text">又拍云</span>
										</label>
									</div>
								</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('attachmentOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
					<!-- 邮箱 -->
					<div id="email" class="tab-pane fade">
						<form class="form-horizontal" id="emailOptions">
							<div class="form-group row mt-3">
								<label class="col-form-label col-md-2">邮箱账号:</label>
								<div class="col-md-5">
									<input class="form-control" type="text"
										th:value="${options['email_username']}" name="email_username">
								</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('emailOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
					<!-- 其他设置 -->
					<div id="other" class="tab-pane fade">
						<form class="form-horizontal" id="otherOptions">
							<div class="form-group row mt-3">
								<label class="control-label col-md-2">统计代码：</label>
								<div class="col-md-5">
									<div class="input-group">
										<textarea class="form-control" rows="4"
											th:text="${options['blog_statistics']}"
											th:value="${options['blog_statistics']}"
											name="blog_statistics" style="resize: none"></textarea>
									</div>
								</div>
							</div>
							<div class="tile-footer">
								<div class="row">
									<div class="col-md-8 col-md-offset-3">
										<button class="btn btn-sm btn-outline-primary" type="button"
											onclick="save('otherOptions')">
											<i class="fa fa-fw fa-lg fa-check-circle"></i>保存
										</button>
									</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	</main>
	<div th:replace="admin/module/macros :: comm"></div>
	<script src="/plugins/layer/layer.js"></script>
	<script type="text/javascript">
	
		$(function(){
			selectCommentPlatform();
			
			$('input[name=platform_comment]').click(function(){
				selectCommentPlatform();
			});
		})
		//评论设置平台选择
		function selectCommentPlatform(){
			var gitalk=$("input[value='gitalk']:checked").val();
			var valine=$("input[value='valine']:checked").val();
			console.log(gitalk+valine);
			if(gitalk!=null){
				$(".gitalk-options").show();
			}else{
				$(".gitalk-options").hide();
			}
			if(valine!=null){
				$(".valine-options").show();
			}else{
				$(".valine-options").hide();
			}
		}
		
		//保存设置项
		function save(id) {
			var from = $("#" + id).serialize();
			$.ajax({
				type : "post",
				url : "/admin/option/save",
				data : from,
				dataType : "json",
				success : function(data) {
					showMsg(data.msg, "success", 3000)
				}
			});
		}
		//选择logo
		function openChoice(id) {
			layer.open({
				type : 2,
				title : '所有附件',
				anim : 2,
				area : [ '90%', '90%' ],
				shadeClose: true,
				maxmin : true,
				content : "profile/openChoice/" + id
			});
		}
		//推送百度
		function pushBaidu() {
			var token = $("#baiduToken").val();
			$.ajax({
				url : "/admin/article/pushBaidu",
				type : "post",
				data : {
					token : token
				},
				dataType : "json",
				success : function(data) {
					if (data.flag == true) {
						showMsg(data.msg, "success", 3000);
					} else if (data.flag == false) {
						showMsg(data.msg, "error", 3000);
					}
				}
			});
		}
	</script>
</body>
</html>